$(document).ajaxSend(function(e, xhr, opt){
    var token = localStorage.getItem("userInfo_token");
    xhr.setRequestHeader("userInfo_token", token);
});

function getUserInfo(url){
    $.ajax({
        url: url,
        type: "get",
        success: function(result){
            if(result.code == "SUCCESS"){
                var author = result.data;
                $(".container .left .card h3").text(author.userName);
                $(".container .left .card a").attr("href", author.githubUrl);
            }else{
                alert(result.errMsg);
            }
        },
        error: function(error){
            if(error != null && error.status == 401){
                location.href = "blog_login.html";
            }
        }
    });
}

function logout(){
    localStorage.removeItem("userInfo_token");
    location.href = "blog_login.html";
}
